#include <bits/stdc++.h>
#define ll long long
#define str string
#define ld long double
#define run_vasya_run ios_base::sync_with_stdio(0) , cin.tie(0) ,cout.tie(0)
#define ull unsigned long long
#define open freopen ("input.txt", "r", stdin);
#define close freopen("output.txt", "w", stdout);
using namespace std;
const ll MOD = 998244353;
ll _ , n , pred , mx , mn;
str s;
int main()
{
run_vasya_run;
open;
close;
int _;
_ = 1;
while(_ --)
{
cin >> n >> s;
pred = -1;
mx = -1e9;
mn = 1e9;
for(int i = 0; i < n; i ++)
{
if(s[i] == '1')
{
if(pred == -1)
{
pred = i;
continue;
}
mx = max(mx, i - pred);
mn = min(mn, i - pred);
pred = i;
}
}
if(mx == mn)
{
cout << "YES";
}
else
{
cout << "NO";
}
}
}
1719B - Mathematical Circus | 1719C - Fighting Tournament |
1642A - Hard Way | 285C - Building Permutation |
1719E - Fibonacci Strings | 1696C - Fishingprince Plays With Array |
1085A - Right-Left Cipher | 1508B - Almost Sorted |
1690C - Restoring the Duration of Tasks | 1055A - Metro |
1036D - Vasya and Arrays | 1139C - Edgy Trees |
37A - Towers | 353A - Domino |
409H - A + B Strikes Back | 1262A - Math Problem |
158C - Cd and pwd commands | 194A - Exams |
1673B - A Perfectly Balanced String | 1104B - Game with string |
1169B - Pairs | 1567D - Expression Evaluation Error |
78A - Haiku | 1287A - Angry Students |
1428A - Box is Pull | 234B - Reading |
581B - Luxurious Houses | 1481C - Fence Painting |
935A - Fafa and his Company | 22A - Second Order Statistics |